// 商品准入-待完善
import {
  PRODUCT_TYPE_OPTIONS,
  PIC_STATE_OPTIONS,
  ACCESS_SPU_STATE_OPTIONS
} from '@/constants/commodity';
import { getUserInfoListService } from '@/api/usercenter';
import { getAuthDepartmentsFn } from '@/pages/commodity/modules/utils/salePriceRequireUtils';

const FORM_ITEM_LIST = [
  {
    prop: 'productNameFinal',
    label: '商品名称',
    type: 'input'
  },
  {
    prop: 'categoryPath',
    label: '分类',
    type: 'input',
  },
  {
    prop: 'spuNo',
    label: 'SPU编码',
    type: 'input',
    searchType: 'EQ'
  },
  {
    prop: 'productType',
    label: '商品类型',
    type: 'select',
    clearable: true,
    options: PRODUCT_TYPE_OPTIONS,
  },
  {
    prop: 'brandName',
    label: '商品品牌',
    type: 'input',
  },
  {
    prop: 'createOper',
    label: '创建人',
    type: 'select',
    searchType: 'EQ',
    remote: true,
    remoteMethod: getUserInfoListService,
    paramKey: 'userName',
    optionKeys: { valueKey: 'userIdStr', labelKey: 'userName', codeKey: 'jobNumber' }
  },
  {
    prop: 'picStateInfo',
    label: '图文完善状态',
    type: 'select',
    clearable: true,
    options: PIC_STATE_OPTIONS,
    searchType: 'EQ'
  },
  {
    prop: 'productAdmitState',
    label: '完善状态',
    type: 'select',
    options: ACCESS_SPU_STATE_OPTIONS,
    searchType: 'EQ',
    defaultVal: '0'
  }
]
const initTableColumns = (parent) => {
  return [
    {
      title: 'SPU编码',
      key: 'spuNo',
      fixed: 'left'
    },
    {
      title: '商品名称',
      key: 'productNameFinal',
      fixed: 'left'
    },
    {
      title: '分类',
      key: 'categoryPath'
    },
    {
      title: '品牌',
      key: 'brandName'
    },
    {
      title: '商品类型',
      key: 'productTypeStr'
    },
    {
      title: '归属部门',
      render: (h, { row }) => <div>{ getAuthDepartmentsFn(row) }</div>
    },
    {
      title: '管理区域',
      key: 'manageAreaName'
    },
    {
      title: '创建人',
      key: 'createOperName'
    },
    {
      title: '创建人部门',
      key: 'createOperDeptName'
    },
    {
      title: '创建日期',
      key: 'createOpeTime'
    },
    {
      title: '商品架构信息',
      render: (h, { row }) => {
        if (row.addStateDTO && parent.showBtn('架构信息')) {
          const { structureInfoAddState, structureInfoAddStateStr } = row.addStateDTO;
          return (
            <el-link
              type = { parent.formatLinkType(structureInfoAddState) }
              onClick = {() => parent.handleJumpNewPage('structureInfoAddState', row, structureInfoAddState)}
            >
              { structureInfoAddStateStr }
            </el-link>
          );
        }
      }
    },
    {
      title: '商品基本信息',
      render: (h, { row }) => {
        if (row.addStateDTO && parent.showBtn('基本信息')) {
          const { basicInfoAddState, basicInfoAddStateStr } = row.addStateDTO;
          return (
            <el-link
              type = { parent.formatLinkType(basicInfoAddState) }
              onClick = {() => parent.handleJumpNewPage('basicInfoAddState', row, basicInfoAddState)}
            >
              { basicInfoAddStateStr }
            </el-link>
          );
        }
      }
    },
    {
      title: '商品管理信息',
      render: (h, { row }) => {
        if (row.addStateDTO && parent.showBtn('管理信息')) {
          const { manageAddState, manageAddStateStr } = row.addStateDTO;
          return (
            <el-link
              type = { parent.formatLinkType(manageAddState) }
              onClick = {() => parent.handleJumpNewPage('manageAddState', row, manageAddState)}
            >
              { manageAddStateStr }
            </el-link>
          );
        }
      }
    },
    {
      title: '商品SKU信息(包装)',
      width: 150,
      render: (h, { row }) => {
        if (row.addStateDTO && parent.showBtn('SKU信息')) {
          const { packageAddState, packageAddStateStr } = row.addStateDTO;
          return (
            <el-link
              type = { parent.formatLinkType(packageAddState) }
              onClick = {() => parent.handleJumpNewPage('packageAddState', row, packageAddState)}
            >
              { packageAddStateStr }
            </el-link>
          );
        }
      }
    },
    {
      title: '供货信息',
      render: (h, { row }) => {
        if (row.addStateDTO && parent.showBtn('供货信息')) {
          const { supplyGoodsAddState, supplyGoodsAddStateStr } = row.addStateDTO;
          return (
            <el-link
              type = { parent.formatLinkType(supplyGoodsAddState) }
              onClick = {() => parent.handleJumpNewPage('supplyGoodsAddState', row, supplyGoodsAddState, supplyGoodsAddStateStr)}
            >
              { supplyGoodsAddStateStr }
            </el-link>
          );
        }
      }
    },
    {
      title: '售价信息',
      render: (h, { row }) => {
        if (row.addStateDTO && parent.showBtn('售价信息')) {
          const { salePriceAddState, salePriceAddStateStr } = row.addStateDTO;
          return (
            <el-link
              type = { parent.formatLinkType(salePriceAddState) }
              onClick = {() => parent.handleJumpNewPage('salePriceAddState', row, salePriceAddState, salePriceAddStateStr)}
            >
              { salePriceAddStateStr }
            </el-link>
          );
        }
      }
    },
    {
      title: '图文介绍',
      render: (h, { row }) => {
        if (row.addStateDTO && parent.showBtn('图文信息')) {
          const { picAddState, picAddStateStr } = row.addStateDTO;
          return (
            <el-link
              type = { parent.formatLinkType(picAddState) }
              onClick = {() => parent.handleJumpNewPage('picAddState', row, picAddState)}
            >
              { picAddStateStr }
            </el-link>
          );
        }
      }
    },
    {
      title: '验收标准',
      render: (h, { row }) => {
        if (row.addStateDTO && parent.showBtn('验收标准')) {
          const { acceptanceAddState, acceptanceAddStateStr } = row.addStateDTO;
          return (
            <el-link
              type = { parent.formatLinkType(acceptanceAddState) }
              onClick = {() => parent.handleJumpNewPage('acceptanceAddState', row, acceptanceAddState)}
            >
              { acceptanceAddStateStr }
            </el-link>
          );
        }
      }
    },
    {
      title: '资质信息',
      render: (h, { row }) => {
        if (row.addStateDTO && parent.showBtn('资质')) {
          const { qualificationAddState, qualificationAddStateStr } = row.addStateDTO;
          return (
            <el-link
              type = { parent.formatLinkType(qualificationAddState) }
              onClick = {() => parent.handleJumpNewPage('qualificationAddState', row, qualificationAddState)}
            >
              { qualificationAddStateStr }
            </el-link>
          );
        }
      }
    },
  ]
}
export {
  FORM_ITEM_LIST,
  initTableColumns
}
